﻿
namespace MyWebApp.Web
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using System.Data.Linq;
    using System.Web.Ria;
    using System.Web.Ria.Data;
    using System.Web.DomainServices;
    using System.Data;
    using System.Web.DomainServices.LinqToEntities;


    // Implements application logic using the AdventureWorks_DataEntities context.
    // TODO: Add your application logic to these methods or in additional methods.
    [EnableClientAccess()]
    public class ProductService : LinqToEntitiesDomainService<AdventureWorks_DataEntities>
    {

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Product> GetProduct()
        {
            return this.Context.Product;
        }

        public IQueryable<Product> GetProducts()
        {
            DataLoadOptions loadOpts = new DataLoadOptions();
            loadOpts.LoadWith<Product>(p => p.ProductSubcategoryID);
            // this.Context.LoadOptions = loadOpts;         
           
            return this.Context.Product;
        }

    }
}


